// 闭包隐藏真实的数据  只提供 API

function createCache() {
  const data = {};
  return {
    set: function (key, val) {
      data[key] = val;
      console.log(`set ${key} success`);
      return this;
    },
    get: function (key) {
      return data[key];
    },
  };
}

const c = createCache();

console.log(c.set("hh", 222));
console.log(c.get("hh"));
console.log(c.get("h"));
